import java.io.Serializable;


public class Note implements Serializable{
	private static final long serialVersionUID = 5239951658767763054L;
	private int pitch;
	private int velocity;
	private double duration;
	private boolean selected = false;
	public static final int MAX_DURATION = 9;
	
	public Note()
	{
		setDuration(1);
		setVelocity(Constant.midiVolume);
	}
	
	public Note(int pitch)
	{
		this();
		this.setPitch(pitch);
	}
	
	public Note(int pitch, int velocity, double duration)
	{
		this.setPitch(pitch);
		this.setVelocity(velocity);
		this.setDuration(duration);
	}
	
	public int getPitch() {
		return pitch;
	}

	public void setPitch(int pitch) {
		this.pitch = pitch;
	}
	
	public void changePitch(int delta)
	{
		this.pitch += delta;
	}

	public int getVelocity() {
		return velocity;
	}

	public void setVelocity(int velocity) {
		this.velocity = velocity;
	}
	
	public double getDuration() {
		return duration;
	}

	public void setDuration(double duration) {
		this.duration = duration;
	}

	public void increaseDuration() {
		if (this.duration == Note.MAX_DURATION)
			this.duration = 1;
		else this.duration +=1;
	}
	public void resetDuration() {
		this.resetDuration(1);
	}
	public void resetDuration(int newDuration) {
		this.duration = newDuration;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	
}
